function arrtoObj(arr) {
  const obj = {};
  for (let index = 0; index < arr.length; index++) {
    const element = arr[index];
    if (!obj[element]) {
      obj[element] = 1;
    } else {
      obj[element]++;
    }
  }
  return obj;
}
const maxObj = (obj) => {
  let max = 0;
  let maxKey = null;
  for (const key in obj) {
    if (obj[key] > max) {
      max = obj[key];
      maxKey = key;
    }
  }
  return { max, maxKey };
};
console.log(arrtoObj(["b", "c", "b", "c", "a", "b", "c", "ss", "s", "a"]));
console.log(
  maxObj(arrtoObj(["b", "c", "b", "c", "a", "b", "c", "ss", "s", "a"]))
);
const unique = (arr) => {
  let obj = {};
  let result = [];
  for (let index = 0; index < arr.length; index++) {
    const element = arr[index];
    if (!obj[element]) {
      obj[element] = 1;
      result = [...result, element];
    }
  }
  return result;
};
console.log(unique(["b", "c", "b", "c", "a", "b", "c", "ss", "s", "a"]));
